package com.xw.service.xw.feedback;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Service;

import com.xw.dao.DaoSupport;
import com.xw.entity.Page;
import com.xw.entity.xw.Feedback;
import com.xw.entity.xw.Patient;
import com.xw.util.PageData;


@Service("feedbackService")
public class FeedbackService {
	@Resource(name = "sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	@Resource(name = "daoSupport")
	private DaoSupport daoSupport;
	
	/**
	 * 新增疗效反馈
	 * @param feedback
	 * @throws Exception 
	 */
	public void add(Feedback feedback) throws Exception {
		daoSupport.save("FeedbackMapper.add",feedback);
	}
	
	/**
	 * 删除疗效反馈
	 * @param pd
	 * @throws Exception 
	 */
	public void delete(PageData pd) throws Exception {
		daoSupport.delete("FeedbackMapper.deleteById", pd);
	}
	
	
	/**
	 * 根据ID获取一条信息 
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public Feedback getOne(PageData pd) throws Exception {
		Feedback feedBack = null;
		feedBack = (Feedback) daoSupport.findForObject("FeedbackMapper.getOne", pd);
		return feedBack;
	}
	
	
	/**
	 * 修改疗效反馈信息
	 * @param Feedback
	 * @throws Exception 
	 */
	public void edit(Feedback feedback) throws Exception {
		daoSupport.update("FeedbackMapper.editFeedback", feedback);
	}
	
	
	/**
	 * 获取疗效反馈列表
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	public List<PageData> getList(Page page) throws Exception {
		List<PageData> list=null;
		list=(List<PageData>) daoSupport.findForList("FeedbackMapper.getList_listPage", page);
		return list;
	}
	

	/**
	 * 根据患者姓名和电话获取患者信息 
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public Patient findHz(PageData pd) throws Exception {
		Patient patient = null;
		patient = (Patient) daoSupport.findForObject("FeedbackMapper.findHz", pd);
		return patient;
	}
	
	
	/**
	 * 批量删除反馈信息
	 */
	public void deleteAll(String[] USER_IDS) throws Exception {
		daoSupport.delete("FeedbackMapper.deleteAll", USER_IDS);
	}
	
		
}
